#include "listroom.h"
#include "ui_listroom.h"

#include "connection.h"

ListRoom::ListRoom(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ListRoom)
{
    ui->setupUi(this);

    tblRoom = new QSqlTableModel(this);
    tblRoom->setTable("\"V_ROOM\"");
    tblRoom->select();

    ui->tableKab->setModel(tblRoom);
    ui->tableKab->setWordWrap(true);

    setNameFields();
}

ListRoom::~ListRoom()
{
    delete ui;
}

void ListRoom::setNameFields()
{

    tblRoom->setHeaderData(room_num, Qt::Horizontal, tr("Num room"));
    tblRoom->setHeaderData(roomtype_name, Qt::Horizontal, tr("Type room"));
    tblRoom->setHeaderData(room_about, Qt::Horizontal, tr("Description"));
    //tblRoom->setHeaderData(ViewKab_fam_io, Qt::Horizontal, tr("Managing an office"));

    ui->tableKab->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->tableKab->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableKab->setEditTriggers(QAbstractItemView::NoEditTriggers);

    ui->tableKab->setColumnHidden(men_respond_id, true);
    ui->tableKab->setColumnHidden(roomtype_id, true);

    ui->tableKab->resizeColumnsToContents();

    QHeaderView *header = ui->tableKab->horizontalHeader();
    header->setStretchLastSection(true);
}
